package com.zjq.designpatterns.creation.simplefactory.code;/*
 * 版权信息: 北京千⾥马网信科技有限公司</br>
 * Copyright ©2008-2018. All rights reserved. 京ICP备16007318号
 */

/**
 * 可以使用反射
 * @author jessie
 * @version 1.0
 * @date 2021/1/14
 */
public class VideoFactory2 {
    public Video getVideo(Class cls){
        Video video = null;
        try {
            video = (Video) Class.forName(cls.getName()).newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return video;
    }
}
